<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html lang="en">
<head>
<base href="<%=basePath%>">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<link rel="stylesheet"
	href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="${pageContext.request.contextPath}/js/jqueryui.js"></script>
<script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<title>团购后台管理系统</title>

<script>
	$(function() {
		$("#startDate").datepicker();
		$("#startDate").datepicker("option", "dateFormat", "yy-mm-dd");
	})
</script>
<style>
.main_div {
	min-width: 1000px;
}

.pageChange {
	float: right;
	color: #337ab7;
}

.pageChange>span {
	cursor: pointer
}

.pageChange>span:hover {
	color: blue
}
</style>
</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div" style="height:40px">
					<div class="main_title">
						<span>团购管理</span>
					</div>
						<input style="display:none" value="5" id="pageCount"
						name="pageCount" />
				</div>
				<div class="force-overflow1-1">
					<table id="showtable"
						class="table table-condensed table-bordered table-hover"
						style="text-align: center">
						<tr style="background-color: #59c7d2">
							<th style="text-align: center">序号</th>
							<th style="text-align: center">商品缩略图</th>
							<th style="text-align: center">商品详情图</th>
							<th style="text-align: center">商品名称</th>
							<th style="text-align: center">门市价</th>
							<th style="text-align: center">团购价格</th>
							<th style="text-align: center">商品数量</th>
							<th style="text-align: center">详情</th>
							<th style="text-align: center">是否上架</th>
						</tr>
					</table>
					<div class="pageChange" style="margin-bottom:30px">
						<span onclick="prePage()">&nbsp;&nbsp;上一页&nbsp;&nbsp;</span> <span
							onclick="nextPage()">&nbsp;&nbsp;下一页&nbsp;&nbsp;</span> <em>
							&nbsp; 第&nbsp;<span id="pageNum">1</span>&nbsp;页&nbsp;&nbsp;
						</em> <em>/&nbsp;&nbsp;共&nbsp;<span id="totalpage"></span>&nbsp;页
						</em> <em>&nbsp;&nbsp;&nbsp;跳到第<input id="searchInput"
							style="width:46px" maxlength="4" type="text">页
						</em>
						<button class="btn btn-primary" onclick="searchPage()">搜索</button>
					</div>
				</div>
			</div>
		</section>
		<script>
			$(function() {
				selectinfo();
			})
			
			function selectinfo() {
				var pageNum = $("#pageNum").html();
				var pageCount = $("#pageCount").val();
				$.post(urls + "seckillAction/selectSeckillProductList",
					{
						typeId : 1,
						pageNum : pageNum,
						pageCount : pageCount,
						otherId:localStorage.getItem("otherid"),
						status:-5
					},
					function(data) {
						//console.log(data)
						if (data) {
							var totalpage = data.totalpage;
							var orderlist = data.list;
							var table = $("#showtable");
							$("tr").remove(".addtr");
							for (var i = 0; i < orderlist.length; i++) {
								var status="";
								if (orderlist[i].status == 1) {
									status = "<input onclick='controlGroup(\"" + orderlist[i].id + "\",5)' type='button' class='btn btn-success' value='点击上架' />"
								} else if (orderlist[i].status == 5) {
									status = "<input onclick='controlGroup(\"" + orderlist[i].id + "\",1)' type='button' class='btn btn-danger' value='点击下架' />"
								}
								var append = "<tr id='" + orderlist[i].id + "'  class='addtr'><td style='line-height:120px'>" + (i + 1) + "</td>" +
									"<td ><img style='width:250px;height:120px' src='/seckills/" + orderlist[i].productImg + "' alt='加载中'/> </td>" +
									"<td ><img style='width:250px;height:120px' src='/seckills/" + orderlist[i].publicityImg + "' alt='加载中'/> </td>" +
									"<td style='line-height:120px'>" + orderlist[i].productName + "</td>" +
									"<td style='line-height:120px'>" + orderlist[i].productPrice + "</td>" +
									"<td style='line-height:120px'>" + orderlist[i].seckillPrice + "</td>" +
									"<td style='line-height:120px'>" + orderlist[i].inventory + "</td>" +
									"<td  style='vertical-align:middle;'>" + orderlist[i].details + "</td>" +
									"<td style='line-height:120px'>" + status + "</td></tr>";
								table.append(append);
							}
							$("#totalpage").html(totalpage);
						}
					}
					, "json"
				)
			}
			function controlGroup(id, status) {
				$.post(urls + "otherAction/putawaySeckillProduct",
					{
						id : id,
						status : status
					},
					function(res) {
						if (res == true) {
							alert("操作成功");
							selectinfo();
						} else {
							alert("操作失败")
						}
					}
				)
			}
		</script>
	</div>
</body>
</html>
